import java.io.File;
import java.io.IOException;

import jxl.Sheet;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;

public class JxlExpExcel
{

	public static void main(String[] args)
	{
		String[] title = {"name","gender","age"};

		//当前文件的路径
		String cur_dir = System.getProperty("user.dir");
		System.out.println(cur_dir);
		
		File file =new File("jxl_excel.xls");  //不能为xlsx格式
		try
		{
			//创建EXCEl
			file.createNewFile();
			WritableWorkbook wb= Workbook.createWorkbook(file);
			WritableSheet sheet = wb.createSheet("sheet1", 0);
			Label  label = null;
			
			//设置标题
			for(int i = 0; i < title.length; i++)
			{
				label = new Label(i, 0, title[i]);
				sheet.addCell(label);
			}
			
			for(int i = 1;i<10; i++)
			{
				label = new Label(0,i,"user"+i);
				sheet.addCell(label);
				
				label = new Label(1,i,"男");
				sheet.addCell(label);
				
				label = new Label(2,i,String.valueOf(10+i));
				sheet.addCell(label);
			}
			
			//写入数据
			wb.write();
			wb.close();
		}
		catch (Exception e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}

}
